; (function (window, undefined) {
  function init(el) {
    let els = document.querySelectorAll(el)
    els.forEach((item, i) => {
      this[i] = els[i]
      this.length = els.length
    })
  }
  let jQuery = function (el) {
    return new init(el)
  }
  jQuery.extend = function (object) {
    for (let key in object) {
      init.prototype[key] = object[key]
    }
  }
  //console.log(this); 
  init.prototype = {
    css(cssName, cssVal) {
      for (let i = 0; i < this.length; i++) {
        this[i].style[cssName] = cssVal

      }
      return this
    },
    /*   let arr = []
      arr.push.apply(this, els) */
    //底层的一些方法，待完善(别问，问就是菜)
    attr(cssName, cssVal) {
      // 如果传入的参数为两个
      if (arguments.length == 2) {
        for (let i = 0; i < this.length; i++) {
          this[i][cssName] = cssVal
        }
        // 如果传放的为一个参数
      } else {
        // 获取属性
        return this[0][cssName]
      }
      return this;
    },
    ajax(options) { }
  }
  window.jQuery = window.$ = jQuery
})(window)
